<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    //创建ajax对象
    const xhr = new XMLHttpRequest()
    //设置请求方式与请求地址
    xhr.open('get','http://localhost:3000/goods/getGoods?id=1')
    //检测状态是否改变
    xhr.onreadystatechange=function(){
        //请求状态4，表示请求结束，可以获取相应
        if(xhr.readyState===4){
            //成功获取响应
            if (xhr.status===200) {
                console.log(JSON.parse(xhr.responseText));
            }
        }
    }
    //发送请求
    xhr.send()
</script>